//
//  LLMyOrderTableViewCell.m
//  LoveLove
//
//  Created by 达迩科技 on 2019/4/10.
//  Copyright © 2019 wkf. All rights reserved.
//

#import "LLMyOrderTableViewCell.h"

@implementation LLMyOrderTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView{
    
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, LLScreenWidth-20, 222)];
    bgView.layer.masksToBounds = YES;
    bgView.layer.cornerRadius = 15;
    bgView.backgroundColor = LLWhiteColor;
    [self.contentView addSubview:bgView];
    
    self.nameButton = [LLInitBaseViewTool buttonWithTitle:@"钢琴教育店   >" image:nil titleColor:LLColor(0, 0, 0) font:12];
    self.nameButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    self.nameButton.frame = CGRectMake(18, 16, bgView.width-36, 12);
    [self.nameButton addTarget:self action:@selector(didSelectType:) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:self.nameButton];
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:self.nameButton.titleLabel.text];
    NSRange range1 = [self.priceLabel.text rangeOfString:@">"];
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:LLColorRGB(199) range:range1];
    self.nameButton.titleLabel.attributedText = AttributedStr;
    
    
    self.bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(18, 50, 93, 93)];
    self.bgImage.image = [UIImage imageNamed:@"课程图片"];
    self.bgImage.layer.masksToBounds = YES;
    self.bgImage.layer.cornerRadius = 5;
    self.bgImage.contentMode = UIViewContentModeScaleAspectFill;
    [bgView addSubview:self.bgImage];
    
    self.titleLabel = [LLInitBaseViewTool labelWithText:@"满200-100元优惠券满200-100元优惠券优惠券满200-100元优惠券券元.." textColor:LLColorRGB(0) font:13 textAlignment:NSTextAlignmentLeft];
    self.titleLabel.numberOfLines = 2;
    self.titleLabel.frame = CGRectMake(124, 50, bgView.width-124-15, 35);
    [bgView addSubview:self.titleLabel];
    
    self.priceLabel = [LLInitBaseViewTool labelWithText:@"￥1" textColor:LLColor(231, 11, 11) font:13 textAlignment:NSTextAlignmentLeft];
    self.priceLabel.frame = CGRectMake(124, 130, LLScreenWidth-124-15, 13);
    [bgView addSubview:self.priceLabel];
    NSMutableAttributedString *AttributedStr123 = [[NSMutableAttributedString alloc]initWithString:self.priceLabel.text];
    NSRange range21 = [self.priceLabel.text rangeOfString:@"￥"];
    [AttributedStr123 addAttribute:NSFontAttributeName value:LLRegularFont(10) range:range21];
    self.priceLabel.attributedText = AttributedStr123;
    
    
    for (int i=0; i<2; i++) {
        LLButton *button = [LLInitBaseViewTool buttonWithTitle:nil image:nil titleColor:LLColorRGB(95) font:15];
        button.layer.masksToBounds = YES;
        button.layer.cornerRadius= 13.5;
        button.tag = i;
        button.layer.borderWidth = 1;
        if (i==0) {
            [button setTitle:@"取消订单" forState:0];
            [button setTitleColor:LLColorRGB(95) forState:0];
            button.layer.borderColor = LLColorRGB(128).CGColor;
            button.frame = CGRectMake(bgView.width-15-76*2-17, 185, 76, 27);
            button.tag = 1;
        } else {
            [button setTitle:@"评 价" forState:0];
            [button setTitleColor:LLColor(225, 0, 0) forState:0];
            button.layer.borderColor = LLColor(225, 0, 0).CGColor;
            button.frame = CGRectMake(bgView.width-15-76, 185, 76, 27);
            button.tag = 2;
        }
        [button addTarget:self action:@selector(didSelectType:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:button];
    }
}

- (void)didSelectType:(LLButton *)button{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectButton:didClickItem:)]) {
        [self.delegate didSelectButton:self didClickItem:button.tag];
    }

}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
